﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZX.BLL.Extend;
using System.Data;
using System.Data.SqlClient;
using ZX.SPL.ORM;
using ZX.DBModule;
using ZX.Common;
using ZX.Common.Extend;
using ZX.DAL.DBExtend;

namespace ZX.BPM.Library
{
    public class BHF_TaskInstanceView : BaseBussnies
    {
        
        ///// <summary>
        ///// 获取待办任务
        ///// </summary>
        ///// <param name="WorkflowID"></param>
        ///// <param name="WorkflowInfo"></param>
        ///// <param name="UserID"></param>
        ///// <param name="PageIndex"></param>
        ///// <param name="PageSize"></param>
        //public IList<BaseEntity> GetTaskInstanceList(string WorkflowID, string WorkflowInfo, string UserID, int PageIndex, int PageSize)
        //{

        //    //@PageIndex				--页索引
        //    //@PageSize				--页大小
        //    SqlParameter[] sqlparams = new SqlParameter[]{
        //        new SqlParameter("@WorkflowID",SqlDbType.VarChar,100),
        //        new SqlParameter("@WorkflowInfo",SqlDbType.VarChar,200),
        //        new SqlParameter("@UserID",SqlDbType.VarChar,100),
        //        new SqlParameter("@PageIndex",SqlDbType.Int,1),
        //        new SqlParameter("@PageSize",SqlDbType.Int,1)
        //     };

        //    IList<BaseEntity> results = new List<BaseEntity>(); 
        //    sqlparams[0].Value = WorkflowID;
        //    sqlparams[1].Value = WorkflowInfo;
        //    sqlparams[2].Value = UserID;
        //    sqlparams[3].Value = PageIndex;
        //    sqlparams[4].Value = PageSize;
        //    DataSet ds = this.RunProcedure("sp_GetWaitingTaskList", sqlparams);
        //    if (ds != null && ds.Tables.Count > 0)
        //    {
        //        DataTable dt = ds.Tables[0];
        //        //ZX.SPL.ORM.ObjectMapper om = new SPL.ORM.ObjectMapper(new V_HF_TaskInstanceView());

        //        results = om.DatatableToObject(dt);
               
        //    }

        //    return results;
        //}

        ///// <summary>
        ///// 获取待办任务
        ///// </summary>
        ///// <param name="WorkflowID"></param>
        ///// <param name="WorkflowInfo"></param>
        ///// <param name="UserID"></param>
        ///// <param name="PageIndex"></param>
        ///// <param name="PageSize"></param>
        //public DataTable GetTaskDatatable(string WorkflowID, string WorkflowInfo, string UserID, int PageIndex, int PageSize)
        //{
        //    SqlParameter[] sqlparams = new SqlParameter[]{
        //        new SqlParameter("@WorkflowID",SqlDbType.VarChar,100),
        //        new SqlParameter("@WorkflowInfo",SqlDbType.VarChar,200),
        //        new SqlParameter("@UserID",SqlDbType.VarChar,100),
        //        new SqlParameter("@PageIndex",SqlDbType.Int,1),
        //        new SqlParameter("@PageSize",SqlDbType.Int,1)
        //     };

        //    IList<BaseEntity> results = new List<BaseEntity>();
        //    sqlparams[0].Value = WorkflowID;
        //    sqlparams[1].Value = WorkflowInfo;
        //    sqlparams[2].Value = UserID;
        //    sqlparams[3].Value = PageIndex;
        //    sqlparams[4].Value = PageSize;
        //    DataSet ds = this.RunProcedure("sp_GetWaitingTaskList", sqlparams);
        //    DataTable boundTable=null;
        //    ///******************todo zhuyun********************/
        //    //if (!string.IsNullOrEmpty(selectname))
        //    //{
        //    //    DataTable orders = ds.Tables[0];
        //    //    var query =
        //    //        from order in orders.AsEnumerable()
        //    //        where order.Field<string>("FlowInstanceCaption").Contains(selectname)
        //    //        select order;
        //    //    boundTable = query.CopyToDataTable<DataRow>();
        //    //}
        //    ///******************todo zhuyun********************/
        //    if (ds != null && ds.Tables.Count > 0)
        //    {
        //        if (boundTable!=null)
        //        {
        //            return boundTable;
        //        }
        //        else
        //        {
        //            return ds.Tables[0];
        //        }        
        //    }
        //    else
        //        return null;
        //}

        ///// <summary>
        ///// 获取待办任务数
        ///// </summary>
        ///// <param name="WorkflowID"></param>
        ///// <param name="WorkflowInfo"></param>
        ///// <param name="UserID"></param>
        ///// <param name="PageIndex"></param>
        ///// <param name="PageSize"></param>
        //public int GetTaskInstanceCount(string WorkflowID, string WorkflowInfo, string UserID, int PageIndex, int PageSize)
        //{

        //    //@WorkflowID				--流程模版ID
        //    //@WorkflowInfo			--流程信息(编号或标题)
        //    //@UserID					--用户ID 
        //    //@PageIndex				--页索引
        //    //@PageSize				--页大小
        //    SqlParameter[] sqlparams = new SqlParameter[]{
        //        new SqlParameter("@WorkflowID",SqlDbType.VarChar,100),
        //        new SqlParameter("@WorkflowInfo",SqlDbType.VarChar,200),
        //        new SqlParameter("@UserID",SqlDbType.VarChar,100),
        //        new SqlParameter("@PageIndex",SqlDbType.Int,1),
        //        new SqlParameter("@PageSize",SqlDbType.Int,1)
        //     };
        //    int count = 0;
        //    sqlparams[0].Value = WorkflowID;
        //    sqlparams[1].Value = WorkflowInfo;
        //    sqlparams[2].Value = UserID;
        //    sqlparams[3].Value = PageIndex;
        //    sqlparams[4].Value = PageSize;
        //    DataSet ds = this.RunProcedure("sp_GetWaitingTaskCount", sqlparams);
        //    if (ds != null && ds.Tables.Count > 0)
        //    {
        //        //TaskList = ZX.Common.Globals.JSonToObject<IList<V_HF_TaskInstanceView>>(blist.ToJSON());
        //        if (ds.Tables[0].Rows.Count > 0) 
        //        {
        //            count =(ds.Tables[0].Rows[0]["TotalCount"] == null) ? 0 : Convert.ToInt32(ds.Tables[0].Rows[0]["TotalCount"]); 
        //        }
        //    }

        //    return count;
        //    //IList<V_HF_TaskInstanceView>
        //}
        ///// <summary>
        ///// 获取待办任务
        ///// </summary>
        ///// <param name="WorkflowID"></param>
        ///// <param name="WorkflowInfo"></param>
        ///// <param name="UserID"></param>
        ///// <param name="PageIndex"></param>
        ///// <param name="PageSize"></param>
        //public DataSet GetTaskInstanceClassList(string UserID)
        //{
        //    //@UserID	--用户ID 
        //     SqlParameter[] sqlparams = new SqlParameter[]{
        //      new SqlParameter("@UserID",SqlDbType.VarChar,100),
             
        //     };
        //     sqlparams[0].Value = UserID;
        //     DataSet ds = this.RunProcedure("sp_GetWaitingTaskTotal", sqlparams);
        //     return ds;
        // }
        ///// <summary>
        ///// 取得待确认考勤记录数
        ///// </summary>
        ///// <param name="employeeID"></param>
        //public int GetWorkResult(string employeeID)
        //{
        //    string sql = string.Format("select COUNT(*) as totalCount from wkWorkResult where IsValidate='N' and WkStatus not in('正常出勤','非工作日','项目中','加班')  and EmployeeID ='{0}'", employeeID);
        //    DbSql dbsql = new DbSql();
        //    return dbsql.ExecuteScalar(sql);
        //}
        ///// <summary>
        ///// 根据部门OR姓名获取人员
        ///// </summary>
        ///// <param name="deptid"></param>
        ///// <param name="name"></param>
        ///// <returns></returns>
        //public DataTable GetDatUser(string deptid, string name)
        //{
        //    string sql="";
        //    if(name==string.Empty||name=="")
        //    {
        //        sql = string.Format("select Top 50 * from V_TrSendQuestionnaireUser where cast(DeptID as varchar(50))='{0}'", deptid);
        //    }
        //    else if (deptid == string.Empty || deptid == "")
        //    {
        //        sql = string.Format("select Top 50 * from V_TrSendQuestionnaireUser where  Name like '%{0}%'",name);
        //    }
        //    else if(deptid=="sczx")
        //    {
        //        sql = name;
        //    }
        //    else
        //    {
        //        sql = string.Format("select Top 50 * from V_TrSendQuestionnaireUser where cast(DeptID as varchar(50))='{0}' or Name like '%{1}%'", deptid, name);
        //    }
        //    DbSql dbsql = new DbSql();
        //    return dbsql.ExecuteQuery(sql);
        //}
    }
}